
<?php if($child_id){?>
<div class="box">
  <div class="box-content">
  
    <ul class="box-filter">
    
     <?php if ($categories) { ?>
            <?php foreach ($categories as $category) { ?>
			<li><span><?php echo $category['name']; ?></span>
            <ul>
				<?php foreach ($category['children'] as $children ) { ?>
                	<?php if (in_array($children['category_id'], $filter_category)) { ?>
                  <li>
                    <input data-title="<?php echo str_replace(' ','-',$category['name']); ?>" type="checkbox" value="<?php echo $children['category_id']; ?>" id="filter<?php echo $children['category_id']; ?>" checked="checked" />
                    <label for="filter<?php echo $children['category_id']; ?>"><?php echo $children['name']; ?></label>
                  </li>
                  <?php } else { ?>
                  <li>
                    <input data-title="<?php echo str_replace('-',' ',$category['name']); ?>" type="checkbox" value="<?php echo $children['category_id']; ?>" id="filter<?php echo $children['category_id']; ?>" />
                    <label for="filter<?php echo $children['category_id']; ?>"><?php echo $children['name']; ?></label>
                  </li>
                  <?php } ?>
              <?php } ?>
            </ul>
            <a href="#">покажи всички</a>
          </li>
		 <?php } ?>
	<?php } ?>
      
    </ul>
  </div>
</div>
<script type="text/javascript"><!--
$('#button-filter').bind('click', function() {
	filter = [];
	
	$('.box-filter input[type=\'checkbox\']:checked').each(function(element) {
		filter.push(this.value);
	});
	
	location = '<?php echo $action; ?>&filter=' + filter.join(',');
});

$('.box-filter input').change(function(){
	var category = $(this).attr('data-title');
	filter = [];
	
	$('.box-filter input[type=\'checkbox\']:checked').each(function(element) {
		filter.push(this.value);
	});
	
	if(filter.length){
	location = '<?php echo $action; ?>&filter=' + filter.join(',');
	}else{
		location = '/продукти#' + category;
	}
	});
//--></script> 
<?php }?>